<template>
  <el-pagination
    class="mgt20"
    v-if="show"
    background
    @current-change="pageChange"
    :current-page="page"
    :page-size="size"
    layout="prev, pager, next"
    :total="total">
  </el-pagination>
</template>

<script>
  export default {
    name: 'Pagination',
    props: {
      page: '',
      size: {
        default: 15
      },
      total: {
        default: 0
      }
    },
    data() {
      return {
        show: false
      }
    },

    methods: {
      pageChange(n) {
        this.$emit('change', n)
      }
    },

    watch: {
      'total'(n) {
        this.show = this.total > this.size
      }
    }
  }
</script>
